﻿@model ShopBarModel
@using SmartStore.Web.Models.Common;
@{ 
	if (IsStoreClosed)
	{
		return;
	}

	string accountUrl = Model.IsAuthenticated ? Url.Action("Info", "Customer") : Url.RouteUrl("Login", new { returnUrl = Request.RawUrl });
	var labelStyle = GetThemeVariable<string>("shopbar-label", "warning");
	var isRtl = this.WorkContext.WorkingLanguage.Rtl;
}

<div class="shopbar-col shopbar-tools" data-summary-href="@Url.Action("CartSummary", "ShoppingCart", new { cart = Model.ShoppingCartEnabled, wishlist = Model.WishlistEnabled, compare = Model.CompareProductsEnabled })">

	<!-- Hamburger Menu -->
	<div class="shopbar-tool d-lg-none" id="shopbar-menu">
		<a class="shopbar-button" href="#" data-toggle="offcanvas" data-autohide="true" data-placement="@(isRtl ? "right" : "left")" data-fullscreen="false" data-disablescrolling="true" data-target="#offcanvas-menu">
			<span class="shopbar-button-icon">
				<i class="icm icm-menu"></i>
			</span>
			<span class="shopbar-button-label-sm">
				@T("Common.Menu")
			</span>
		</a>
	</div>

    @{ Html.RenderWidget("shopbar_tools_before"); }

	<!-- User -->
	<div class="shopbar-tool d-lg-none" id="shopbar-user">
		<a class="shopbar-button" href="@accountUrl">
			<span class="shopbar-button-icon">
				<i class="icm icm-user"></i>
			</span>
			<span class="shopbar-button-label-sm">
				@T(Model.IsAuthenticated ? "Account.MyAccount" : "Account.Login")
			</span>
		</a>
	</div>

	@if (Model.CompareProductsEnabled)
	{
		<div class="shopbar-tool" id="shopbar-compare" data-target="#compare-tab">
			<a href="@Url.Action("CompareProducts", "Catalog")"  class="shopbar-button navbar-toggler" data-toggle="offcanvas" data-summary-href="@Url.Action("CartSummary", "ShoppingCart", new { compare = true })"
			   data-autohide="true" data-placement="@(isRtl ? "left" : "right")" data-fullscreen="false" data-disablescrolling="true" data-target="#offcanvas-cart">
				<span class="shopbar-button-icon">
					<i class="icm icm-repeat"></i>
					<span class='badge badge-pill label-cart-amount badge-@labelStyle' style="@(Model.CompareItemsCount == 0 ? "display:none" : "")" data-bind-to="CompareItemsCount">@Model.CompareItemsCount</span>
				</span>
				<span class="shopbar-button-label">
					<span>@T("Common.Shopbar.CompareProductsPartOne")</span><br />
					<strong>@T("Common.Shopbar.CompareProductsPartTwo")</strong>
				</span>
				<span class="shopbar-button-label-sm">
					@T("Common.Shopbar.Compare")
				</span>
			</a>
		</div>
	}

	@if (Model.WishlistEnabled)
	{
		<div class="shopbar-tool" id="shopbar-wishlist" data-target="#wishlist-tab">
			<a href="@Url.RouteUrl("Wishlist")" class="shopbar-button navbar-toggler" data-toggle="offcanvas" data-summary-href="@Url.Action("CartSummary", "ShoppingCart", new { wishlist = true })"
				data-autohide="true" data-placement="@(isRtl ? "left" : "right")" data-fullscreen="false" data-disablescrolling="true" data-target="#offcanvas-cart">
				<span class="shopbar-button-icon">
					<i class="icm icm-heart"></i>
					<span class='badge badge-pill label-cart-amount badge-@labelStyle' style="@(Model.WishlistItemsCount == 0 ? "display:none" : "")" data-bind-to="WishlistItemsCount">@Model.WishlistItemsCount</span>
				</span>
				<span class="shopbar-button-label">
					<span>@T("Common.Shopbar.WishlistPartOne")</span><br />
					<strong>@T("Common.Shopbar.WishlistPartTwo")</strong>
				</span>
				<span class="shopbar-button-label-sm">
					@T("Wishlist")
				</span>
			</a>
		</div>
	}

	@if (Model.ShoppingCartEnabled)
	{
		<div class="shopbar-tool" id="shopbar-cart" data-target="#cart-tab">
			<a href="@Url.RouteUrl("ShoppingCart")" class="shopbar-button navbar-toggler" data-toggle="offcanvas" data-summary-href="@Url.Action("CartSummary", "ShoppingCart", new { cart = true })"
			   data-autohide="true" data-placement="@(isRtl ? "left" : "right")" data-fullscreen="false" data-disablescrolling="true" data-target="#offcanvas-cart">
				<span class="shopbar-button-icon">
					<i class="icm icm-bag"></i>
					<span class='badge badge-pill label-cart-amount badge-@(labelStyle)' style="@(Model.CartItemsCount == 0 ? "display:none" : "")" data-bind-to="CartItemsCount">
						@Model.CartItemsCount
					</span>
				</span>
				<span class="shopbar-button-label">
					<span>@T("Common.Shopbar.BasketPartOne")</span><br />
					<strong>@T("Common.Shopbar.BasketPartTwo")</strong>
				</span>
				<span class="shopbar-button-label-sm">
					@T("Common.Shopbar.Basket")
				</span>
			</a>
		</div>
	}

    @{ Html.RenderWidget("shopbar_tools_after"); }

</div>

@using (Html.BeginZoneContent("aftercontent", key: "offcanvas-menu"))
{
	<aside id="offcanvas-menu" class="offcanvas offcanvas-overlay offcanvas-@(isRtl ? "right" : "left") offcanvas-shadow" data-blocker="true" data-overlay="true">
        <div class="offcanvas-content">
            <div id="offcanvas-menu-container" data-url="@(Url.Action("OffCanvas", "Menu"))">
                <!-- AJAX -->
            </div>
        </div>
	</aside>
}

@using (Html.BeginZoneContent("aftercontent", key: "offcanvas-cart"))
{
	<aside id="offcanvas-cart" class="offcanvas offcanvas-lg offcanvas-overlay offcanvas-@(isRtl ? "left" : "right") offcanvas-shadow" data-lg="true" data-blocker="true" data-overlay="true">
		<div class="offcanvas-content">
			@Html.Action("OffCanvasCart", "ShoppingCart", new { area = "" })
		</div>
	</aside>
}